﻿#ifndef GEOMTURBOFILEREADER_H
#define GEOMTURBOFILEREADER_H

#include "ModuleBase/ThreadTask.h"
#include <QFile>
#include <QHash>
#include <QString>
#include "ModuleBase/messageWindowBase.h"

class TopoDS_Edge;
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>

namespace GUI
{
	class MainWindow;
} // namespace name

namespace MainWidget
{
	class C3fdGeomTurboFileReader : public ModuleBase::ThreadTask
	{
		Q_OBJECT
	public:
		C3fdGeomTurboFileReader(GUI::MainWindow *mw, const QStringList &files, bool readHubAndShroud);
		~C3fdGeomTurboFileReader();

		void run() override;

		void setRenderer(vtkSmartPointer<vtkRenderer>);

	signals:
		void showMessage(ModuleBase::Message);
		void finishRead();

	private:
		void parse(QStringList files);
		bool parseHubData(QFile &file);
		bool parseShroudData(QFile &file);
		bool parseSuctionData(QFile &file);
		bool parsePressureData(QFile &file);
		QList<double> zrToXyz(double z, double r);
		QList<QList<double>> parseSectionData(QFile &file, bool *ok = nullptr);
		TopoDS_Edge createSpline(QList<QList<double>> points);

		void sendErrorMessage(QString);

	private:
		QStringList m_Files = {};
		bool m_ReadHubAndShroud = false;
		/// 叶根数据hub（Z=轴向，R=径向）
		QList<QList<double>> m_Hub = {};
		/// 叶顶数据shroud（Z=轴向，R=径向）
		QList<QList<double>> m_Shroud = {};
		/// 叶片数据blade（X=径向，Y=周向，Z=轴向）
		QList<QList<QList<double>>> m_Suction = {};
		QList<QList<QList<double>>> m_Pressure = {};
		/// 叶片数量
		int m_NumOfBlades = 0;
		/// 叶片数量
		double m_Tolerance = 1e-006;

		vtkSmartPointer<vtkRenderer> m_Renderer = nullptr;

	};

}

#endif